package com.ibm.spatiotemp.tools;

import java.util.Date;

import com.ibm.json.java.JSONArray;
import com.ibm.json.java.JSONObject;

public class STSPointObject extends STSObject {
	private static final String TYPE = "Point";
	private JSONArray coordinates = new JSONArray();
	private long t;
	
	public void setSTSPoint(long t, double x, double y) {
		this.t = t;
		coordinates.add(new Double(x));
		coordinates.add(new Double(y));
	}
	
	public void setSTSPoint(STSPoint p) {
		this.t = p.t;
		coordinates.add(new Double(p.x));
		coordinates.add(new Double(p.y));
	}
	
	@Override
	public JSONObject toJSONObject() {
		JSONObject json = new JSONObject();
		json.put("type", TYPE);
		json.put("coordinates", coordinates);
		JSONArray times = new JSONArray();
		times.add(ThreadLocalDateUtil.formatSTTime(new Date(t)));
		json.put("times", times);				
		return json;
	}


}
